package project.adapter;

import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import approve.action.R;
import project.dao.pr_projectDAO;
import project.model.PrComment;

public class Projectdetail_error_adapter_tc extends BaseAdapter implements OnClickListener {

	private Context context;
	private List<PrComment> listcomment;
	pr_projectDAO prodao=new pr_projectDAO();
	
	public Projectdetail_error_adapter_tc(Context context,List<PrComment> listcomment){
		this.context=context;
		this.listcomment=listcomment;
	}
	public int getCount() {
		// TODO Auto-generated method stub
		return listcomment.size();
	}

	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return listcomment.get(position);
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		PrComment entry=listcomment.get(position);
		if(convertView==null){
			LayoutInflater inflater=(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView=inflater.inflate(R.layout.listerror_row, null);
		}
		TextView tvTitleError=(TextView)convertView.findViewById(R.id.titleError);
		String comment=entry.getCommentview();
		Spannable WordtoSpan = new SpannableString(comment);        
		WordtoSpan.setSpan(new ForegroundColorSpan(Color.parseColor(entry.getColorText())), 0, comment.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
		tvTitleError.setText(WordtoSpan);
		
		TextView tvPhone = (TextView) convertView.findViewById(R.id.tvMobile);
        tvPhone.setText(entry.getEmployeeName_()+"-"+entry.getDisplayDate());
		return convertView;
	}

	public void onClick(View arg0) {
		// TODO Auto-generated method stub
		
	}

}
